package com.starbaba.invitate.view;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.opensymphony.xwork2.ModelDriven;
import com.starbaba.core.utils.PropertyParamMapBuilder;
import com.starbaba.core.utils.Struts2Utils;
import com.starbaba.core.utils.json.JsonUtils;
import com.starbaba.core.web.page.PageResponse;
import com.starbaba.core.web.struts2.BaseAction;
import com.starbaba.invitate.model.InvitateFriendStat;
import com.starbaba.invitate.service.InvitateFriendStatService;


@SuppressWarnings({"rawtypes", "unchecked", "serial"})
public class InvitateFriendStatAction extends BaseAction implements ModelDriven<InvitateFriendStat>{

	private InvitateFriendStatService service;
	
	@Autowired
	@Qualifier("invitateFriendStatService")
	public void setService(InvitateFriendStatService service) {
		this.service = service;
	}
	
	public String showPage() throws Exception{
		return "success";
	}
	
	public void queryList(){
		paramsMap = PropertyParamMapBuilder.buildFromHttpRequest(Struts2Utils.getRequest(), paramsMap);
		parsePageRequest();
		PageResponse pageResponse = new PageResponse();
		int start = pageRequest.getIDisplayStart();
		int length = pageRequest.getIDisplayLength();

		try {
			List<InvitateFriendStat> list = new ArrayList<InvitateFriendStat>();
			list = service.getList(start, length, pageResponse, paramsMap);

			pageResponse.setAaData(list);
			pageResponse.setSEcho(pageRequest.getSEcho());

			sendJsonMessage(JsonUtils.toJson(pageResponse, null, true, null, false));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public InvitateFriendStat getModel() {
		
		return null;
	}
	
}
